package com.jiezhuo.config.mybatis;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {
    @Primary
    @Bean(name = "iotCenter")
    @ConfigurationProperties(prefix = "spring.datasource.center")
    public DataSource dataSourceCenter() {
        return DruidDataSourceBuilder.create().build();
    }

    @Primary
    @Bean(name = "iotCenterDataSourceProperties")
    @ConfigurationProperties(prefix = "spring.datasource.center")
    public DataSourceProperties iotCenterDataSourceProperties() {
        return new DataSourceProperties();
    }
//
    //    @Primary
//    @Bean(name = "iot")
//    @ConfigurationProperties(prefix = "spring.datasource.iot")
//    public DataSource dataSourceIot() {
//        return DruidDataSourceBuilder.create().build();
//    }
//
////    @Primary
//    @Bean(name = "iotDataSourceProperties")
//    @ConfigurationProperties(prefix = "spring.datasource.iot")
//    public DataSourceProperties iotDataSourceProperties() {
//        return new DataSourceProperties();
//    }
    @Bean(name = "pg")
    @ConfigurationProperties(prefix = "spring.datasource.pg")
    public DataSource dataSourcepg() {
        return DruidDataSourceBuilder.create().build();
    }

    //    @Primary
    @Bean(name = "pgDataSourceProperties")
    @ConfigurationProperties(prefix = "spring.datasource.pg")
    public DataSourceProperties pgDataSourceProperties() {
        return new DataSourceProperties();
    }

    @Bean(name = "Jss")
    @ConfigurationProperties(prefix = "spring.datasource.jss")
    public DataSource dataSourceJss() {
        return DruidDataSourceBuilder.create().build();
    }

    //    @Primary
    @Bean(name = "JssDataSourceProperties")
    @ConfigurationProperties(prefix = "spring.datasource.jss")
    public DataSourceProperties jssDataSourceProperties() {
        return new DataSourceProperties();
    }



    @Bean(name = "ks")
    @ConfigurationProperties(prefix = "spring.datasource.ks")
    public DataSource dataSourceKs() {
        return DruidDataSourceBuilder.create().build();
    }

    //    @Primary
    @Bean(name = "pgDataSourceProperties")
    @ConfigurationProperties(prefix = "spring.datasource.ks")
    public DataSourceProperties KsDataSourceProperties() {
        return new DataSourceProperties();
    }

//    @Bean(name = "jetlinks")
//    @ConfigurationProperties(prefix = "spring.datasource.jetlinks")
//    public DataSource dataSourceJetlinks() {
//        return DruidDataSourceBuilder.create().build();
//    }
//
////        @Primary
//    @Bean(name = "jetlinksDataSourceProperties")
//    @ConfigurationProperties(prefix = "spring.datasource.jetlinks")
//    public DataSourceProperties jetlinksDataSourceProperties() {
//        return new DataSourceProperties();
//    }
}
